{# SPDX-FileCopyrightText: © Fossology contributors

   SPDX-License-Identifier: FSFAP
#}
var folder = 1;

$("#tree").treeview({
  collapsed: false,
  animated: "fast",
  control: "#sidetreecontrol",
  persist: "location"
  });

$(document).ready(function() {
  $('.clickable-folder').click(function(event){
    folder = $(this).attr('data-folder');
    $('#fromFolder').val(folder);
    $.getJSON("?mod=foldercontents&folder=" + folder{% if removable is defined %} + "&removable=1"{% endif %})
        .done(function (data) {
          var folderchild = $('#foldercontent');
          folderchild.empty();
          $.each(data, function (key, value) {
            var option = document.createElement("option");
            option.innerHTML = value;
            option.value = key;
            folderchild.append(option);
          });
          sortList('#foldercontent option');
        })
        .fail(failed);
    return false;
  });
  $('#foldercontent').click(function(event){
    if (this.value == -1) {
      $('#movebutton').attr('disabled',true);
    }
    else {
      $('#movebutton').attr('disabled',false);
    }
  });

  $('.clickable-folder').first().trigger('click');
});

